package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 *集合转数组
 * */
public class CollectionTOArrayDemo {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("onr");
        c.add("two");
        c.add("three");
        c.add("four");
        System.out.println(c);
        //Object[] arr = c.toArray();//不常用
        String[] arr = c.toArray(new String[c.size()]);
      //  String[] arr = c.toArray(new String[10]);
       // String[] arr = c.toArray(new String[1]);
        System.out.println(arr.length);
        System.out.println(Arrays.toString(arr));

    }
}
